package com.hiwhitley.easy.day03;

import java.util.Stack;

/**
 * Created by hiwhitley on 2016/5/25.
 */
public class MyStack {

    public static Stack<Integer> sortStackByStack(Stack<Integer> stack) {
        Stack<Integer> help = new Stack<>();
        while (!stack.isEmpty()) {
            int cur = stack.pop();
            while (!help.isEmpty() && help.peek() < cur) {
                stack.push(help.pop());
            }
            help.push(cur);
        }

        while (!help.isEmpty()) {
            stack.push(help.pop());
        }
        return stack;
    }
}
